CMS 3D CMS Logo

DaqFakeReader.cc
Go to the documentation of this file.
1 
6 #include "DaqFakeReader.h"
10 
12 
14 
16 
17 #include "CLHEP/Random/RandGauss.h"
18 
19 #include <cmath>
20 #include <sys/time.h>
21 #include <cstring>
22 
23 using namespace std;
24 using namespace edm;
25 
27 // construction/destruction
29 
30 //______________________________________________________________________________
32  : runNum(1),
33  eventNum(1),
34  empty_events(pset.getUntrackedParameter<bool>("emptyEvents", false)),
35  meansize(pset.getUntrackedParameter<unsigned int>("meanSize", 1024)),
36  width(pset.getUntrackedParameter<unsigned int>("width", 1024)),
37  injected_errors_per_million_events(pset.getUntrackedParameter<unsigned int>("injectErrPpm", 0)),
38  modulo_error_events(injected_errors_per_million_events ? 1000000 / injected_errors_per_million_events
39  : 0xffffffff) {
40  // mean = pset.getParameter<float>("mean");
41  produces<FEDRawDataCollection>();
42 }
43 
44 //______________________________________________________________________________
46 
48 // implementation of member functions
50 
51 //______________________________________________________________________________
53  // a null pointer is passed, need to allocate the fed collection
54  data = new FEDRawDataCollection();
55  EventID eID = e.id();
56 
57  if (!empty_events) {
58  // Fill the EventID
59  eventNum++;
60  // FIXME:
61 
69 
70  timeval now;
71  gettimeofday(&now, nullptr);
72  fillGTPFED(eID, *data, &now);
73  //TODO: write fake TCDS FED filler
74  }
75  return 1;
76 }
77 
80  FEDRawDataCollection* fedcoll = nullptr;
81  fillRawData(e, fedcoll);
82  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
83  e.put(std::move(bare_product));
84 }
85 
86 //______________________________________________________________________________
88  const int fedmin, const int fedmax, EventID& eID, FEDRawDataCollection& data, float meansize, float width) {
89  // FIXME: last ID included?
90  for (int fedId = fedmin; fedId <= fedmax; ++fedId) {
91  // Generate size...
92  float logsiz = CLHEP::RandGauss::shoot(std::log(meansize), std::log(meansize) - std::log(width / 2.));
93  size_t size = int(std::exp(logsiz));
94  size -= size % 8; // all blocks aligned to 64 bit words
95 
96  FEDRawData& feddata = data.FEDData(fedId);
97  // Allocate space for header+trailer+payload
98  feddata.resize(size + 16);
99 
100  // Generate header
101  FEDHeader::set(feddata.data(),
102  1, // Trigger type
103  eID.event(), // LV1_id (24 bits)
104  0, // BX_id
105  fedId); // source_id
106 
107  // Payload = all 0s...
108 
109  // Generate trailer
110  int crc = 0; // FIXME : get CRC
111  FEDTrailer::set(feddata.data() + 8 + size,
112  size / 8 + 2, // in 64 bit words!!!
113  crc,
114  0, // Evt_stat
115  0); // TTS bits
116  }
117 }
118 
121  FEDRawData& feddata = data.FEDData(fedId);
122  uint32_t size = evf::evtn::SLINK_WORD_SIZE * 37 - 16; //BST52_3BX
123  feddata.resize(size + 16);
124 
125  FEDHeader::set(feddata.data(),
126  1, // Trigger type
127  eID.event(), // LV1_id (24 bits)
128  0, // BX_id
129  fedId); // source_id
130 
131  int crc = 0; // FIXME : get CRC
132  FEDTrailer::set(feddata.data() + 8 + size,
133  size / 8 + 2, // in 64 bit words!!!
134  crc,
135  0, // Evt_stat
136  0); // TTS bits
137 
138  unsigned char* pOffset = feddata.data() + FEDHeader::length;
139  //fill in event ID
140  *((uint32_t*)(pOffset + evf::evtn::EVM_BOARDID_OFFSET * evf::evtn::SLINK_WORD_SIZE / 2)) =
142  *((uint32_t*)(pOffset + FEDHeader::length +
144  //fill in timestamp
145  *((uint32_t*)(pOffset + evf::evtn::EVM_GTFE_BSTGPS_OFFSET * evf::evtn::SLINK_WORD_SIZE / 2)) = now->tv_sec;
147  evf::evtn::SLINK_HALFWORD_SIZE)) = now->tv_usec;
148 
149  //*( (uint16_t*) (pOffset + (evtn::EVM_GTFE_BLOCK*2 + evtn::EVM_TCS_LSBLNR_OFFSET)*evtn::SLINK_HALFWORD_SIZE)) = (unsigned short)fakeLs_-1;
150 
151  //we could also generate lumiblock, bcr, orbit,... but they are not currently used by the FRD input source
152 }
153 
155  std::cout << "DaqFakeReader begin Lumi " << iL.luminosityBlock() << std::endl;
156  fakeLs_ = iL.luminosityBlock();
157 }
DeadROC_duringRun.runNum
runNum
Definition: DeadROC_duringRun.py:21
FEDNumbering.h
evf::evtn::EVM_BOARDID_OFFSET
const unsigned int EVM_BOARDID_OFFSET
Definition: GlobalEventNumber.h:29
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
electrons_cff.bool
bool
Definition: electrons_cff.py:372
FEDNumbering::MINECALFEDID
Definition: FEDNumbering.h:43
DaqFakeReader::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: DaqFakeReader.cc:78
funct::false
false
Definition: Factorize.h:34
DaqFakeReader::empty_events
bool empty_events
Definition: DaqFakeReader.h:50
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
edm
HLT enums.
Definition: AlignableModifier.h:19
DaqFakeReader::fillRawData
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Definition: DaqFakeReader.cc:52
evf::evtn::EVM_GTFE_BSTGPS_OFFSET
const unsigned int EVM_GTFE_BSTGPS_OFFSET
Definition: GlobalEventNumber.h:36
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DaqFakeReader::DaqFakeReader
DaqFakeReader(const edm::ParameterSet &pset)
Definition: DaqFakeReader.cc:31
FEDNumbering::MAXCSCFEDID
Definition: FEDNumbering.h:52
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
FEDNumbering::MINRPCFEDID
Definition: FEDNumbering.h:59
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
fileCollector.now
now
Definition: fileCollector.py:207
DaqFakeReader::meansize
unsigned int meansize
Definition: DaqFakeReader.h:51
FEDNumbering::MAXSiPixelFEDID
Definition: FEDNumbering.h:28
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
EcalFEDMonitor_cfi.FEDRawDataCollection
FEDRawDataCollection
Definition: EcalFEDMonitor_cfi.py:6
FEDNumbering::MAXDTFEDID
Definition: FEDNumbering.h:56
DaqFakeReader::eventNum
edm::EventNumber_t eventNum
Definition: DaqFakeReader.h:49
FEDNumbering::MAXSiStripFEDID
Definition: FEDNumbering.h:30
evf::evtn::EVM_BOARDID_VALUE
const unsigned int EVM_BOARDID_VALUE
Definition: GlobalEventNumber.h:32
edm::ParameterSet
Definition: ParameterSet.h:36
DaqFakeReader.h
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
createfilelist.int
int
Definition: createfilelist.py:10
DaqFakeReader::fillGTPFED
void fillGTPFED(edm::EventID &eID, FEDRawDataCollection &data, timeval *now)
Definition: DaqFakeReader.cc:119
FEDHeader::length
static const uint32_t length
Definition: FEDHeader.h:54
edm::EventSetup
Definition: EventSetup.h:57
FEDNumbering::MINCSCFEDID
Definition: FEDNumbering.h:51
evf::evtn::SLINK_HALFWORD_SIZE
const unsigned int SLINK_HALFWORD_SIZE
Definition: GlobalEventNumber.h:12
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:82
FEDNumbering::MINDTFEDID
Definition: FEDNumbering.h:55
FEDTrailer::set
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
DaqFakeReader::width
unsigned int width
Definition: DaqFakeReader.h:52
DaqFakeReader::fillFEDs
void fillFEDs(const int, const int, edm::EventID &eID, FEDRawDataCollection &data, float meansize, float width)
Definition: DaqFakeReader.cc:87
FEDNumbering::MINSiPixelFEDID
Definition: FEDNumbering.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DaqFakeReader::fakeLs_
unsigned int fakeLs_
Definition: DaqFakeReader.h:55
GlobalEventNumber.h
FEDNumbering::MINHCALFEDID
Definition: FEDNumbering.h:47
FEDHeader::set
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
evf::evtn::EVM_TCS_TRIGNR_OFFSET
const unsigned int EVM_TCS_TRIGNR_OFFSET
Definition: GlobalEventNumber.h:40
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
evf::evtn::SLINK_WORD_SIZE
const unsigned int SLINK_WORD_SIZE
Definition: GlobalEventNumber.h:11
FEDNumbering::MAXRPCFEDID
Definition: FEDNumbering.h:60
DaqFakeReader::~DaqFakeReader
~DaqFakeReader() override
Definition: DaqFakeReader.cc:45
ParameterSet.h
FEDNumbering::MAXHCALFEDID
Definition: FEDNumbering.h:48
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::EventID
Definition: EventID.h:31
edm::Event
Definition: Event.h:73
FEDHeader.h
evf::evtn::EVM_BOARDID_SHIFT
const unsigned int EVM_BOARDID_SHIFT
Definition: GlobalEventNumber.h:31
DaqFakeReader::beginLuminosityBlock
virtual void beginLuminosityBlock(edm::LuminosityBlock const &iL, edm::EventSetup const &iE)
Definition: DaqFakeReader.cc:154
FEDNumbering::MAXECALFEDID
Definition: FEDNumbering.h:44
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
FEDNumbering::MINTriggerGTPFEDID
Definition: FEDNumbering.h:61
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29
FEDTrailer.h