CMS 3D CMS Logo

DTDigiToRawModule.cc
Go to the documentation of this file.
7 
11 
13 
14 #include <iostream>
15 
16 using namespace edm;
17 using namespace std;
18 
20  produces<FEDRawDataCollection>();
21 
22  dduID = ps.getUntrackedParameter<int>("dduID", 770);
23  debug = ps.getUntrackedParameter<bool>("debugMode", false);
24  digicoll = consumes<DTDigiCollection>(ps.getParameter<edm::InputTag>("digiColl"));
25  mapToken_ = esConsumes<DTReadOutMapping, DTReadOutMappingRcd>();
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
50  edm::ESHandle<DTReadOutMapping> map = iSetup.getHandle(mapToken_);
51 
52  // Create the packed data
53  int FEDIDmin = 0, FEDIDMax = 0;
54  if (useStandardFEDid_) {
55  FEDIDmin = FEDNumbering::MINDTFEDID;
56  FEDIDMax = FEDNumbering::MAXDTFEDID;
57  } else {
58  FEDIDmin = minFEDid_;
59  FEDIDMax = maxFEDid_;
60  }
61 
62  for (int id = FEDIDmin; id <= FEDIDMax; ++id) {
63  packer->SetdduID(id);
64  FEDRawData* rawData = packer->createFedBuffers(*digis, map);
65 
66  FEDRawData& fedRawData = fed_buffers->FEDData(id);
68  delete rawData;
69 
70  FEDHeader dtFEDHeader(fedRawData.data());
71  dtFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, id);
72 
73  FEDTrailer dtFEDTrailer(fedRawData.data() + (fedRawData.size() - 8));
74  dtFEDTrailer.set(fedRawData.data() + (fedRawData.size() - 8),
75  fedRawData.size() / 8,
76  evf::compute_crc(fedRawData.data(), fedRawData.size()),
77  0,
78  0);
79  }
80  // Put the raw data to the event
81  e.put(std::move(fed_buffers));
82 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
T getUntrackedParameter(std::string const &, T const &) const
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.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
DTDigiToRawModule(const edm::ParameterSet &pset)
Constructor.
#define debug
Definition: HDRShower.cc:19
HLT enums.
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