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