26 if (mCCDBServer.size() > 0) {
27 mgr.setURL(mCCDBServer);
29 LOG(info) <<
"Initialization of ZDC Test Digitization " << mgr.getURL();
36 LOG(info) <<
"Loaded SimCondition for timestamp " << mgr.getTimestamp();
37 mSimCondition->
print();
44 LOG(info) <<
"Loaded ModuleConfig for timestamp " << mgr.getTimestamp();
45 mModuleConfig->
print();
54 LOG(fatal) <<
"Setting mask for non existing channel " << ich;
61 if (mCache.empty() || mCache.back() <
ir) {
62 mCache.emplace_back();
63 auto& cb = mCache.back();
67 if (mCache.front() >
ir) {
68 mCache.emplace_front();
69 auto& cb = mCache.front();
73 for (
auto cb = mCache.begin(); cb != mCache.end(); cb++) {
78 auto cbnew = mCache.emplace(cb);
83 return mCache.front();
88 float myShift,
bool hasJitter)
94 float shift = hasJitter ? gRandom->Gaus(0, mSimCondition->
channels[ic].pedestalNoise) : 0;
95 int pos_min = mSimCondition->
channels[ic].ampMinID;
96 int nbx = mSimCondition->
channels[ic].shape.size();
100 for (Int_t ib = 0; ib < NBC2Cache; ib++) {
101 auto*
bc = getBCCache(
ir);
104 auto& bcd = getCreateBCData(
ir);
105 bcd.channels = bcd.channels | mMask[ic];
107 int sample = TMath::Nint(pos_min +
TSN * (sbcd - myShift) + shift +
TSNH);
109 if (sample >= 0 && sample < nbx) {
110 double y = mSimCondition->
channels[ic].shape[sample];
111 bc->data[ic][
i] +=
y * myAmp;
127 for (
auto bc = mCache.begin();
bc != mCache.end();
bc++) {
128 if (zdcOrbitData.empty() ||
bc->orbit != zdcOrbitData.back().ir.orbit) {
129 auto& od = zdcOrbitData.emplace_back();
130 od.ir.orbit =
bc->orbit;
134 auto base_m = mSimCondition->
channels[ic].pedestal;
135 auto base_s = mSimCondition->
channels[ic].pedestalFluct;
136 auto base_n = mSimCondition->
channels[ic].pedestalNoise;
140 float mean_sum = 12. * nba * base_m;
141 float rms_sum = 12. * 2. * base_s * std::sqrt(nba / 2.);
142 float rms_noise_sum = base_n * std::sqrt(12. * nba);
143 float ped = gRandom->Gaus(mean_sum, rms_sum) + gRandom->Gaus(0, rms_noise_sum);
144 int16_t peds = std::round(ped / nba / 12. / mModuleConfig->
baselineFactor);
145 if (peds < SHRT_MIN) {
147 }
else if (peds > SHRT_MAX) {
155 auto& bcd = getCreateBCData(*
bc);
156 bcd.ref.setFirstEntry(zdcChData.size());
157 uint32_t nstored = 0;
160 if (bcd.channels & mMask[ic]) {
161 Double_t meanp = mSimCondition->
channels[ic].pedestal;
162 Double_t sigmab = mSimCondition->
channels[ic].pedestalFluct;
166 Double_t yval = TMath::Nint(
bc->data[ic][
i] + gRandom->Gaus(meanp, sigmab));
169 }
else if (yval <
ADCMin) {
173 bc->digi[ic][
i] = yval;
177 zdcChData.emplace_back(ic,
bc->digi[ic]);
181 bcd.ref.setEntries(nstored);
189 zdcOrbitData.clear();
197 if (zdcBCData.empty() || zdcBCData.back().ir <
ir) {
198 zdcBCData.emplace_back();
199 auto&
bc = zdcBCData.back();
203 if (zdcBCData.front().ir >
ir) {
204 zdcBCData.emplace(zdcBCData.begin());
205 auto& cb = zdcBCData.front();
209 for (
auto cb = zdcBCData.begin(); cb != zdcBCData.end(); cb++) {
210 if ((*cb).ir ==
ir) {
214 auto cbnew = zdcBCData.emplace(cb);
219 return zdcBCData.front();
226 for (
auto cb = mCache.begin(); cb != mCache.end(); cb++) {
Fast digitization of a signal of given amplitude and time in pre-allocated bunch containers....
Header to collect LHC related constants.
static BasicCCDBManager & instance()
double add(int ic, float myAmp, const o2::InteractionRecord irpk, float myShift, bool hasJitter=true)
o2::zdc::Digitizer::BCCache & getCreateBCCache(const o2::InteractionRecord &ir)
void setMask(uint32_t ich, uint32_t mask)
constexpr int LHCMaxBunches
constexpr double LHCBunchSpacingNS
constexpr int NTimeBinsPerBC
const std::string CCDBPathConfigSim
const std::string CCDBPathConfigModule
uint16_t bc
bunch crossing ID of interaction
int64_t differenceInBC(const InteractionRecord &other) const
std::array< ChannelSimCondition, NChannels > channels
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)