CMS 3D CMS Logo

DTDigiToRawModule.cc
Go to the documentation of this file.
7 
11 
14 
15 #include <iostream>
16 
17 using namespace edm;
18 using namespace std;
19 
21  produces<FEDRawDataCollection>();
22 
23  dduID = ps.getUntrackedParameter<int>("dduID", 770);
24  debug = ps.getUntrackedParameter<bool>("debugMode", false);
25  digicoll = consumes<DTDigiCollection>(ps.getParameter<edm::InputTag>("digiColl"));
26 
27  useStandardFEDid_ = ps.getUntrackedParameter<bool>("useStandardFEDid", true);
28  minFEDid_ = ps.getUntrackedParameter<int>("minFEDid", 770);
29  maxFEDid_ = ps.getUntrackedParameter<int>("maxFEDid", 775);
30 
31  packer = new DTDigiToRaw(ps);
32  if (debug)
33  cout << "[DTDigiToRawModule]: constructor" << endl;
34 }
35 
37  delete packer;
38  if (debug)
39  cout << "[DTDigiToRawModule]: destructor" << endl;
40 }
41 
43  auto fed_buffers = std::make_unique<FEDRawDataCollection>();
44 
45  // Take digis from the event
47  e.getByToken(digicoll, digis);
48 
49  // Load DTMap
51  iSetup.get<DTReadOutMappingRcd>().get(map);
52 
53  // Create the packed data
54  int FEDIDmin = 0, FEDIDMax = 0;
55  if (useStandardFEDid_) {
56  FEDIDmin = FEDNumbering::MINDTFEDID;
57  FEDIDMax = FEDNumbering::MAXDTFEDID;
58  } else {
59  FEDIDmin = minFEDid_;
60  FEDIDMax = maxFEDid_;
61  }
62 
63  for (int id = FEDIDmin; id <= FEDIDMax; ++id) {
64  packer->SetdduID(id);
65  FEDRawData* rawData = packer->createFedBuffers(*digis, map);
66 
67  FEDRawData& fedRawData = fed_buffers->FEDData(id);
68  fedRawData = *rawData;
69  delete rawData;
70 
71  FEDHeader dtFEDHeader(fedRawData.data());
72  dtFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, id);
73 
74  FEDTrailer dtFEDTrailer(fedRawData.data() + (fedRawData.size() - 8));
75  dtFEDTrailer.set(fedRawData.data() + (fedRawData.size() - 8),
76  fedRawData.size() / 8,
77  evf::compute_crc(fedRawData.data(), fedRawData.size()),
78  0,
79  0);
80  }
81  // Put the raw data to the event
82  e.put(std::move(fed_buffers));
83 }
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:40
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
Definition: FEDTrailer.cc:31
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
~DTDigiToRawModule() override
Destructor.
DTDigiToRawModule(const edm::ParameterSet &pset)
Constructor.
#define debug
Definition: HDRShower.cc:19
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
T get() const
Definition: EventSetup.h:73
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static void set(unsigned char *header, uint8_t triggerType, uint32_t lvl1ID, uint16_t bxID, uint16_t sourceID, uint8_t version=0, bool moreHeaders=false)
Set all fields in the header.
Definition: FEDHeader.cc:25
def move(src, dest)
Definition: eostools.py:511