CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDigiToRawModule.cc
Go to the documentation of this file.
8 
12 
15 
16 #include <iostream>
17 
18 using namespace edm;
19 using namespace std;
20 
22  produces<FEDRawDataCollection>();
23 
24  dduID = ps.getUntrackedParameter<int>("dduID", 770);
25  debug = ps.getUntrackedParameter<bool>("debugMode", false);
26  digicoll = ps.getParameter<edm::InputTag>("digiColl");
27 
28  useStandardFEDid_ = ps.getUntrackedParameter<bool>("useStandardFEDid", true);
29  minFEDid_ = ps.getUntrackedParameter<int>("minFEDid", 770);
30  maxFEDid_ = ps.getUntrackedParameter<int>("maxFEDid", 775);
31 
32  packer = new DTDigiToRaw(ps);
33  if (debug) cout << "[DTDigiToRawModule]: constructor" << endl;
34 }
35 
37  delete packer;
38  if (debug) cout << "[DTDigiToRawModule]: destructor" << endl;
39 }
40 
41 
42 void DTDigiToRawModule::produce(Event & e, const EventSetup& iSetup) {
43 
44  auto_ptr<FEDRawDataCollection> fed_buffers(new FEDRawDataCollection);
45 
46  // Take digis from the event
48  e.getByLabel(digicoll, digis);
49 
50  // Load DTMap
52  iSetup.get<DTReadOutMappingRcd>().get( map );
53 
54  // Create the packed data
55  int FEDIDmin = 0, FEDIDMax = 0;
56  if (useStandardFEDid_){
57  FEDIDmin = FEDNumbering::MINDTFEDID;
58  FEDIDMax = FEDNumbering::MAXDTFEDID;
59  }
60  else {
61  FEDIDmin = minFEDid_;
62  FEDIDMax = maxFEDid_;
63  }
64 
65  for (int id=FEDIDmin; id<=FEDIDMax; ++id){
66 
67  packer->SetdduID(id);
68  FEDRawData* rawData = packer->createFedBuffers(*digis, map);
69 
70  FEDRawData& fedRawData = fed_buffers->FEDData(id);
71  fedRawData = *rawData;
72  delete rawData;
73 
74  FEDHeader dtFEDHeader(fedRawData.data());
75  dtFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, id);
76 
77  FEDTrailer dtFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
78  dtFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8), fedRawData.size()/8, evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
79 
80  }
81  // Put the raw data to the event
82  e.put(fed_buffers);
83 
84 }
85 
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
virtual ~DTDigiToRawModule()
Destructor.
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
Definition: FEDTrailer.cc:44
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
dictionary map
Definition: Association.py:205
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
static void set(unsigned char *header, int evt_ty, int lvl1_ID, int bx_ID, int source_ID, int version=0, bool H=false)
Set all fields in the header.
Definition: FEDHeader.cc:42
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
DTDigiToRawModule(const edm::ParameterSet &pset)
Constructor.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const T & get() const
Definition: EventSetup.h:55
edm::EventID id() const
Definition: EventBase.h:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
tuple cout
Definition: gather_cfg.py:121
#define debug
Definition: MEtoEDMFormat.h:34
virtual void produce(edm::Event &, const edm::EventSetup &)