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_LITE: rawdigi_ = false; break;
38  case READOUT_MODE_ZERO_SUPPRESSED: rawdigi_ = false; break;
39  case READOUT_MODE_PREMIX_RAW: rawdigi_ = false; break;
40  case READOUT_MODE_VIRGIN_RAW: rawdigi_ = true; break;
41  case READOUT_MODE_PROC_RAW: rawdigi_ = true; break;
42  case READOUT_MODE_SCOPE: rawdigi_ = true; break;
43  case READOUT_MODE_INVALID: {
44  if( edm::isDebugEnabled()) {
45  edm::LogWarning("DigiToRawModule")
46  << "[sistrip::DigiToRawModule::DigiToRawModule]"
47  << " UNKNOWN readout mode: " << pset.getParameter<std::string>("FedReadoutMode");
48  }} break;
49  case READOUT_MODE_SPY: {
50  if( edm::isDebugEnabled()) {
51  edm::LogWarning("DigiToRawModule")
52  << "[sistrip::DigiToRawModule::DigiToRawModule]"
53  << " Digi to raw is not supported for spy channel data";
54  }} break;
55  }
56  if(pset.getParameter<bool>("UseWrongDigiType")) {
57  rawdigi_ = !rawdigi_;
58  if( edm::isDebugEnabled()) {
59  edm::LogWarning("DigiToRawModule")
60  << "[sistrip::DigiToRawModule::DigiToRawModule]"
61  << " You are using the wrong type of digis!";
62  }
63  }
64 
65  // Create instance of DigiToRaw formatter
66  digiToRaw_ = new DigiToRaw( mode_, pset.getParameter<bool>("UseFedKey") );
67 
68  if (rawdigi_) {
69  tokenRawDigi = consumes< edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_, inputDigiLabel_));
70  } else {
71  tokenDigi = consumes< edm::DetSetVector<SiStripDigi> >(edm::InputTag(inputModuleLabel_, inputDigiLabel_));
72 
73  }
74 
75  produces<FEDRawDataCollection>();
76 
77  }
78 
79  // -----------------------------------------------------------------------------
82  if ( edm::isDebugEnabled() ) {
83  LogDebug("DigiToRaw")
84  << "[sistrip::DigiToRawModule::~DigiToRawModule]"
85  << " Destructing object...";
86  }
87  if ( digiToRaw_ ) delete digiToRaw_;
88  }
89 
90  // -----------------------------------------------------------------------------
98  const edm::EventSetup& iSetup ) {
99 
100  eventCounter_++;
101 
102  std::auto_ptr<FEDRawDataCollection> buffers( new FEDRawDataCollection );
103 
105  iSetup.get<SiStripFedCablingRcd>().get( cabling );
106 
107  if( rawdigi_ ) {
109  iEvent.getByToken( tokenRawDigi, rawdigis );
110  digiToRaw_->createFedBuffers( iEvent, cabling, rawdigis, buffers );
111  } else {
113  iEvent.getByToken( tokenDigi, digis );
114  digiToRaw_->createFedBuffers( iEvent, cabling, digis, buffers );
115  }
116 
117  iEvent.put( buffers );
118 
119  }
120 
121 }
122 
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
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:113
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