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.getUntrackedParameter<string>("digiColl", "dtunpacker");
27  digibyType = ps.getUntrackedParameter<bool>("digibytype", true);
28 
29  useStandardFEDid_ = ps.getUntrackedParameter<bool>("useStandardFEDid", true);
30  minFEDid_ = ps.getUntrackedParameter<int>("minFEDid", 770);
31  maxFEDid_ = ps.getUntrackedParameter<int>("maxFEDid", 775);
32 
33  packer = new DTDigiToRaw(ps);
34  if (debug) cout << "[DTDigiToRawModule]: constructor" << endl;
35 }
36 
38  delete packer;
39  if (debug) cout << "[DTDigiToRawModule]: destructor" << endl;
40 }
41 
42 
43 void DTDigiToRawModule::produce(Event & e, const EventSetup& iSetup) {
44 
45  auto_ptr<FEDRawDataCollection> fed_buffers(new FEDRawDataCollection);
46 
47  // Take digis from the event
49  if (digibyType) {
50  e.getByType(digis);
51  }
52  else {
53  e.getByLabel(digicoll, digis);
54  }
55 
56  // Load DTMap
58  iSetup.get<DTReadOutMappingRcd>().get( map );
59 
60  // Create the packed data
61  int FEDIDmin = 0, FEDIDMax = 0;
62  if (useStandardFEDid_){
63  FEDIDmin = FEDNumbering::MINDTFEDID;
64  FEDIDMax = FEDNumbering::MAXDTFEDID;
65  }
66  else {
67  FEDIDmin = minFEDid_;
68  FEDIDMax = maxFEDid_;
69  }
70 
71  for (int id=FEDIDmin; id<=FEDIDMax; ++id){
72 
73  packer->SetdduID(id);
74  FEDRawData* rawData = packer->createFedBuffers(*digis, map);
75 
76  FEDRawData& fedRawData = fed_buffers->FEDData(id);
77  fedRawData = *rawData;
78  delete rawData;
79 
80  FEDHeader dtFEDHeader(fedRawData.data());
81  dtFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, id);
82 
83  FEDTrailer dtFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
84  dtFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8), fedRawData.size()/8, evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
85 
86  }
87  // Put the raw data to the event
88  e.put(fed_buffers);
89 
90 }
91 
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
virtual ~DTDigiToRawModule()
Destructor.
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
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:85
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:356
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 &)