CMS 3D CMS Logo

SiStripDigiToRawModule.cc
Go to the documentation of this file.
2 #include "SiStripDigiToRaw.h"
3 
16 #include <cstdlib>
17 
18 namespace sistrip {
19 
20  //fill Descriptions needed to define default parameters
23  desc.add<std::string>("InputModuleLabel", "simSiStripDigis");
24  desc.add<std::string>("InputDigiLabel", "ZeroSuppressed");
25  desc.add<std::string>("FedReadoutMode", "ZERO_SUPPRESSED");
26  desc.add<bool>("UseFedKey", false);
27  desc.add<bool>("UseWrongDigiType", false);
28  desc.add<bool>("CopyBufferHeader", false);
29  desc.add<edm::InputTag>("RawDataTag", edm::InputTag("rawDataCollector"));
30  descriptions.add("SiStripDigiToRawModule",desc);
31  }
32 
33  // -----------------------------------------------------------------------------
38  inputModuleLabel_( pset.getParameter<std::string>( "InputModuleLabel" ) ),
39  inputDigiLabel_( pset.getParameter<std::string>( "InputDigiLabel" ) ),
40  copyBufferHeader_(pset.getParameter<bool>("CopyBufferHeader")),
41  mode_( fedReadoutModeFromString(pset.getParameter<std::string>( "FedReadoutMode" ))),
42  rawdigi_( false ),
44  eventCounter_(0),
45  rawDataTag_(pset.getParameter<edm::InputTag>("RawDataTag"))
46  {
47  if ( edm::isDebugEnabled() ) {
48  LogDebug("DigiToRawModule")
49  << "[sistrip::DigiToRawModule::DigiToRawModule]"
50  << " Constructing object...";
51  }
52 
53 
54  switch(mode_) {
55  case READOUT_MODE_ZERO_SUPPRESSED: rawdigi_ = false; break;
56  case READOUT_MODE_ZERO_SUPPRESSED_FAKE: rawdigi_ = false; break;
57  case READOUT_MODE_ZERO_SUPPRESSED_LITE10: rawdigi_ = false; break;
59  case READOUT_MODE_ZERO_SUPPRESSED_LITE8: rawdigi_ = false; break;
65  case READOUT_MODE_PREMIX_RAW: rawdigi_ = false; break;
66  case READOUT_MODE_VIRGIN_RAW: rawdigi_ = true; break;
67  case READOUT_MODE_PROC_RAW: rawdigi_ = true; break;
68  case READOUT_MODE_SCOPE: rawdigi_ = true; break;
69  case READOUT_MODE_INVALID: {
70  if( edm::isDebugEnabled()) {
71  edm::LogWarning("DigiToRawModule")
72  << "[sistrip::DigiToRawModule::DigiToRawModule]"
73  << " UNKNOWN readout mode: " << pset.getParameter<std::string>("FedReadoutMode");
74  }} break;
75  case READOUT_MODE_SPY: {
76  if( edm::isDebugEnabled()) {
77  edm::LogWarning("DigiToRawModule")
78  << "[sistrip::DigiToRawModule::DigiToRawModule]"
79  << " Digi to raw is not supported for spy channel data";
80  }} break;
81  }
82  if(pset.getParameter<bool>("UseWrongDigiType")) {
83  rawdigi_ = !rawdigi_;
84  if( edm::isDebugEnabled()) {
85  edm::LogWarning("DigiToRawModule")
86  << "[sistrip::DigiToRawModule::DigiToRawModule]"
87  << " You are using the wrong type of digis!";
88  }
89  }
90 
91  // Create instance of DigiToRaw formatter
92  digiToRaw_ = new DigiToRaw( mode_, pset.getParameter<bool>("UseFedKey") );
93 
94  if (rawdigi_) {
95  tokenRawDigi = consumes< edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_, inputDigiLabel_));
96  } else {
97  tokenDigi = consumes< edm::DetSetVector<SiStripDigi> >(edm::InputTag(inputModuleLabel_, inputDigiLabel_));
98  }
99  if (copyBufferHeader_){
100  //CAMM input raw module label or same as digi ????
101  if( edm::isDebugEnabled()) {
102  edm::LogWarning("DigiToRawModule")
103  << "[sistrip::DigiToRawModule::DigiToRawModule]"
104  << "Copying buffer header from collection " << rawDataTag_;
105  }
106  tokenRawBuffer = consumes<FEDRawDataCollection>(rawDataTag_);
107  }
108 
109  produces<FEDRawDataCollection>();
110 
111  }
112 
113  // -----------------------------------------------------------------------------
116  if ( edm::isDebugEnabled() ) {
117  LogDebug("DigiToRaw")
118  << "[sistrip::DigiToRawModule::~DigiToRawModule]"
119  << " Destructing object...";
120  }
121  if ( digiToRaw_ ) delete digiToRaw_;
122  }
123 
124  // -----------------------------------------------------------------------------
132  const edm::EventSetup& iSetup ) {
133 
134  eventCounter_++;
135 
136  auto buffers = std::make_unique<FEDRawDataCollection>();
137 
139  iSetup.get<SiStripFedCablingRcd>().get( cabling );
140 
141  //get buffer header from original rawdata
143  if (copyBufferHeader_){
144  if( edm::isDebugEnabled()) {
145  edm::LogWarning("DigiToRawModule")
146  << "[sistrip::DigiToRawModule::DigiToRawModule]"
147  << "Getting raw buffer: ";
148  }
149  try {
150  iEvent.getByToken( tokenRawBuffer, rawbuffers );
151  } catch (const cms::Exception& e){
152  if( edm::isDebugEnabled()) {
153  edm::LogWarning("DigiToRawModule")
154  << "[sistrip::DigiToRawModule::DigiToRawModule]"
155  << " Failed to get collection " << rawDataTag_;
156  }
157  }
158  }
159 
160  if( rawdigi_ ) {
162  iEvent.getByToken( tokenRawDigi, rawdigis );
163  if (copyBufferHeader_) digiToRaw_->createFedBuffers( iEvent, cabling, rawbuffers, rawdigis, buffers );
164  else digiToRaw_->createFedBuffers( iEvent, cabling, rawdigis, buffers );
165  } else {
167  iEvent.getByToken( tokenDigi, digis );
168  if (copyBufferHeader_) digiToRaw_->createFedBuffers( iEvent, cabling, rawbuffers, digis, buffers );
169  else digiToRaw_->createFedBuffers( iEvent, cabling, digis, buffers );
170  }
171 
172 
173  iEvent.put(std::move(buffers));
174 
175  }
176 
177 }
178 
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection.
edm::EDGetTokenT< FEDRawDataCollection > tokenRawBuffer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define nullptr
sistrip classes
FEDReadoutMode fedReadoutModeFromString(const std::string &readoutModeString)
DigiToRawModule(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void createFedBuffers(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
const T & get() const
Definition: EventSetup.h:59
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > tokenDigi
void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > tokenRawDigi
def move(src, dest)
Definition: eostools.py:510