CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripDigiToRawModule.cc
Go to the documentation of this file.
1 
3 #include "SiStripDigiToRaw.h"
4 
13 #include <cstdlib>
14 
15 namespace sistrip {
16 
17  // -----------------------------------------------------------------------------
22  inputModuleLabel_( pset.getParameter<std::string>( "InputModuleLabel" ) ),
23  inputDigiLabel_( pset.getParameter<std::string>( "InputDigiLabel" ) ),
24  mode_( fedReadoutModeFromString(pset.getParameter<std::string>( "FedReadoutMode" ))),
25  rawdigi_( false ),
26  digiToRaw_(0),
27  eventCounter_(0)
28  {
29  if ( edm::isDebugEnabled() ) {
30  LogDebug("DigiToRawModule")
31  << "[sistrip::DigiToRawModule::DigiToRawModule]"
32  << " Constructing object...";
33  }
34 
35 
36  switch(mode_) {
37  case READOUT_MODE_ZERO_SUPPRESSED: rawdigi_ = false; break;
38  case READOUT_MODE_ZERO_SUPPRESSED_FAKE: rawdigi_ = false; break;
39  case READOUT_MODE_ZERO_SUPPRESSED_LITE10: rawdigi_ = false; break;
41  case READOUT_MODE_ZERO_SUPPRESSED_LITE8: rawdigi_ = false; break;
47  case READOUT_MODE_PREMIX_RAW: rawdigi_ = false; break;
48  case READOUT_MODE_VIRGIN_RAW: rawdigi_ = true; break;
49  case READOUT_MODE_PROC_RAW: rawdigi_ = true; break;
50  case READOUT_MODE_SCOPE: rawdigi_ = true; break;
51  case READOUT_MODE_INVALID: {
52  if( edm::isDebugEnabled()) {
53  edm::LogWarning("DigiToRawModule")
54  << "[sistrip::DigiToRawModule::DigiToRawModule]"
55  << " UNKNOWN readout mode: " << pset.getParameter<std::string>("FedReadoutMode");
56  }} break;
57  case READOUT_MODE_SPY: {
58  if( edm::isDebugEnabled()) {
59  edm::LogWarning("DigiToRawModule")
60  << "[sistrip::DigiToRawModule::DigiToRawModule]"
61  << " Digi to raw is not supported for spy channel data";
62  }} break;
63  }
64  if(pset.getParameter<bool>("UseWrongDigiType")) {
65  rawdigi_ = !rawdigi_;
66  if( edm::isDebugEnabled()) {
67  edm::LogWarning("DigiToRawModule")
68  << "[sistrip::DigiToRawModule::DigiToRawModule]"
69  << " You are using the wrong type of digis!";
70  }
71  }
72 
73  // Create instance of DigiToRaw formatter
74  digiToRaw_ = new DigiToRaw( mode_, pset.getParameter<bool>("UseFedKey") );
75 
76  if (rawdigi_) {
77  tokenRawDigi = consumes< edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_, inputDigiLabel_));
78  } else {
79  tokenDigi = consumes< edm::DetSetVector<SiStripDigi> >(edm::InputTag(inputModuleLabel_, inputDigiLabel_));
80 
81  }
82 
83  produces<FEDRawDataCollection>();
84 
85  }
86 
87  // -----------------------------------------------------------------------------
90  if ( edm::isDebugEnabled() ) {
91  LogDebug("DigiToRaw")
92  << "[sistrip::DigiToRawModule::~DigiToRawModule]"
93  << " Destructing object...";
94  }
95  if ( digiToRaw_ ) delete digiToRaw_;
96  }
97 
98  // -----------------------------------------------------------------------------
106  const edm::EventSetup& iSetup ) {
107 
108  eventCounter_++;
109 
110  std::auto_ptr<FEDRawDataCollection> buffers( new FEDRawDataCollection );
111 
113  iSetup.get<SiStripFedCablingRcd>().get( cabling );
114 
115  if( rawdigi_ ) {
117  iEvent.getByToken( tokenRawDigi, rawdigis );
118  digiToRaw_->createFedBuffers( iEvent, cabling, rawdigis, buffers );
119  } else {
121  iEvent.getByToken( tokenDigi, digis );
122  digiToRaw_->createFedBuffers( iEvent, cabling, digis, buffers );
123  }
124 
125  iEvent.put( buffers );
126 
127  }
128 
129 }
130 
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual void produce(edm::Event &, const edm::EventSetup &)
FEDReadoutMode fedReadoutModeFromString(const std::string &readoutModeString)
DigiToRawModule(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
void createFedBuffers(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > tokenDigi
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > tokenRawDigi